package com.wondersgroup.fjzlpt.console.dao.impl.user;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.wondersgroup.fjzlpt.console.dao.inter.user.UserRoleDAO;

@Repository
public class UserRoleDAOImpl extends BaseJTDAOImpl implements UserRoleDAO{

	@Override
	@Autowired
	@Qualifier("TB_AUTH_USER_ROLE")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}

	public void insert(String userId, String roleId){
		Map map = new HashMap();
		map.put("userId", userId);
		map.put("roleId", roleId);
		this.insert(map);
	}

	public void deleteByUserId(String userId){
		StringBuilder sbud = new StringBuilder("delete from ").append(this.tb.getTableName())
				.append(" where userid=?");
		SQLBean sb = new SQLBean(sbud.toString(), new Object[]{userId});
		this.update(sb);
	}
}
